<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('轮播图配置列表')" />
	<style>
		.myimg{
			width: 30px;
			height: 30px;
		}
	</style>
</head>
<body class="gray-bg">
     <div class="container-div">
		<div class="row">
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="channel:bannerInfoConfig:add">
					<i class="fa fa-plus"></i> 添加
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('channel:bannerInfoConfig:edit')}]];
        var removeFlag = [[${@permission.hasPermi('channel:bannerInfoConfig:remove')}]];
        var prefix = ctx + "channel/bannerInfoConfig";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "轮播图配置",
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'bannerId', 
					title : '',
					visible: false
				},
				{
					align: 'center',
					title : '轮播图',
					formatter: function (value, row, index) {
						return showImg(row);
					}
				},
					{
						visible: editFlag == 'hidden' ? false : true,
						align: 'center',
						formatter: function (value, row, index) {
							return statusTools(row);
						},
						title : '状态'
					},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.bannerId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.bannerId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
		/* 状态显示 */
		function showImg(row) {
				return '<img class=\"myimg\" src="' + row.bannerUrl + '"></img> ';
		}
		/* 状态显示 */
		function statusTools(row) {
			if (row.useStatus == 1) {
				return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.bannerId + '\')"></i> ';
			} else {
				return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.bannerId + '\')"></i> ';
			}
		}
		/* 用户管理启用 */
		function enable(bannerId) {
			$.modal.confirm("确认要启用吗？", function () {
				$.operate.post(prefix + "/changeStatus", {"bannerId": bannerId, "useStatus": 0});
			})
		}
		/* 用户管理启用 */
		function disable(bannerId) {
			$.modal.confirm("确认要停用吗？", function () {
				$.operate.post(prefix + "/changeStatus", {"bannerId": bannerId, "useStatus": 1});
			})
		}
    </script>
</body>
</html>